from khronos import Atomic, Delay

class DatePrinter(Atomic):
    def __init__(self, period, name=None, parent=None, priority=None):
        Atomic.__init__(self, name, parent, priority)
        self.__period = period
        
    def initializer(self):
        if not callable(self.__period):
            period = self.__period
            self.__period = lambda: period
        return self.print_date()
        
    def print_date(self):
        print self.get_timedelta()
        return Delay(self.__period())(activation=self.print_date)
        
